<template>
	<view class="flex-1">
		<view class="flex-1 mx-3">
			<view class="row-ac flex-1 py-2">
				<view class="row-ac flex-1 font-s-3">
					<image :src="fastdetails.logo" class="fast-logo mr-2" mode=""></image>
					<view class="mr-1">{{ fastdetails.expName }}</view>
					<view>{{ fastdetails.number }}</view>
				</view>
				<view class="row-ac font-s-3">
					<view class="mr-3" @click="copyNumber(fastdetails.number)">复制</view>
					<view @click="contactFast(fastdetails.expPhone)">联系快递</view>
				</view>
			</view>
			<view class="flex-1 py-4">
				<view class="flex-1 py-2" v-for="(item,index) in fastlist" :key="index">
					<view class="font-s-4 font-w text-light-muted">时间：{{ item.time }}</view>
					<view class="flex-1 ml-3 font-s-2 mt-1">{{ item.status }}</view>
				</view>
			</view>
			<view class="flex-1 py-3">
				<view class="font-s-35">
					{{ orderdetails.province_name }}{{ orderdetails.city_name}}{{ orderdetails.district_name }}{{ orderdetails.address }}
				</view>
				<view class="mt-1 row-ac text-muted">
					<view>{{ orderdetails.consignee }}</view>
					<view>{{ orderdetails.phone | phoneFilter }}</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		logisticsinquiryUrl,
		orderDetailUrl
	} from "@/api/index.js"
	export default {
		data() {
			return {
				fastdetails: '',
				queryInfo: {
					freight_number: ''
				},
				fastFirst: [],
				fastlist: [],
				orderdetails: ''
			}
		},
		filters: {
			phoneFilter(val) {
				if (val != null) {
					let reg = /^(.{3}).*(.{4})$/;
					return val.replace(reg, "$1****$2");
				}
				return val;
			}
		},
		onLoad(options) {
			this.getOrderDetail(options.orderId)
			this.getFastQuery(options.freightNumber)
		},
		methods: {
			getFastQuery(freightNumber) {
				this.queryInfo.freight_number = freightNumber
				this.$R.get(logisticsinquiryUrl, this.queryInfo).then(res => {
					if (res.data.status == '0') {
						this.fastdetails = res.data.result
						this.fastFirst = {
							time: this.fastdetails.updateTime,
							status: '已安排' + this.fastdetails.expName + '揽收'
						}
						this.fastlist = [...res.data.result.list, this.fastFirst]
						console.log(this.fastlist);
					}
				})
			},
			getOrderDetail(orderId) {
				this.$R.get(orderDetailUrl + orderId + '/').then(res => {
					if (res.code == 200) {
						this.orderdetails = res.data
						console.log(this.orderdetails);
					}
				})
			},
			copyNumber(fastumber) {
				uni.setClipboardData({
					data: fastumber
				});
			},
			contactFast(expPhone) {
				uni.makePhoneCall({
					phoneNumber: expPhone
				});
			}

		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}

	.fast-logo {
		width: 35rpx;
		height: 35rpx;
		border-radius: 50%;
		border: 1rpx solid #999;
	}
</style>